﻿Imports ComponentFactory.Krypton.Toolkit
Imports Rebar.ConcreteStrings


Public Class MainForm


    Private ConStrings As New ClsStrings
    Private ConEncoding As New ClsEncoding
    Private m_UpdateClockDisplay As Boolean = True


#Region "Loading Events, Functions and Subroutines"


    Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        GetTimeAndDate()
        SetEncStatusMenus()

    End Sub


#End Region


    Private Sub mnuAlternateCase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                       Handles mnuAlternateCase.Click


        Me.rtfMain.SelectedText = ConStrings.ToAlternateCase( _
                                  Me.rtfMain.SelectedText, True, True)

    End Sub


    Private Sub NavCheckSet_CheckedButtonChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                                 Handles NavCheckSet.CheckedButtonChanged

        Me.NavHeader.Values.Heading = Me.NavCheckSet.CheckedButton.Values.Text

    End Sub


    Private Sub BtnSpecNavCollapse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSpecNavCollapse.Click

        Me.splMain.SuspendLayout()
        Me.GrbNavigation.SuspendLayout()

        If Me.NavHeader.Orientation = VisualOrientation.Top Then

            Me.NavHeader.Orientation = VisualOrientation.Left
            Me.splMain.SplitterDistance = 30
            Me.NavHeader.Dock = DockStyle.Fill
            Me.NavBorder1.Visible = False
            Me.NavBorder2.Visible = False
            Me.NavBorder3.Visible = False
            Me.BtnOptions.Visible = False
            Me.BtnCharacter.Visible = False
            Me.HeaderClock.Visible = False

            Me.NavHeader.Values.Description = "Please expand this panel to view the " & _
                                              Me.NavHeader.Values.Heading & "."

            Me.BtnSpecNavCollapse.Type = PaletteButtonSpecStyle.ArrowRight
            Me.DisplayUpdateTimer.Enabled = True

        Else

            Me.NavHeader.Orientation = VisualOrientation.Top
            Me.splMain.SplitterDistance = 200
            Me.NavHeader.Dock = DockStyle.Top
            Me.NavBorder1.Visible = True
            Me.NavBorder2.Visible = True
            Me.NavBorder3.Visible = True
            Me.BtnOptions.Visible = True
            Me.BtnCharacter.Visible = True
            Me.HeaderClock.Visible = True
            Me.NavHeader.Values.Description = ""
            Me.BtnSpecNavCollapse.Type = PaletteButtonSpecStyle.ArrowLeft
            Me.DisplayUpdateTimer.Enabled = False

        End If

        Me.splMain.ResumeLayout()
        Me.GrbNavigation.ResumeLayout()

    End Sub


#Region "Date and Time Event and Subroutines"


    Private Sub ClockTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                Handles ClockTimer.Tick

        GetTimeAndDate()

    End Sub


    Private Sub HeaderClock_CollapsedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                             Handles HeaderClock.CollapsedChanged

        GetTimeAndDate()

    End Sub


    Private Sub GetTimeAndDate()

        If Me.HeaderClock.Collapsed Then
            Me.HeaderClock.ValuesPrimary.Heading = Now.ToLongTimeString
        Else
            Me.DigitalClock.DigitText = Now.ToLongTimeString
            Me.HeaderClock.ValuesPrimary.Heading = Now.ToLongDateString
        End If

    End Sub


#End Region


#Region "EDITOR Status Toolbar Events and Subroutines"


    Private Sub mnuEncDefault_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                    Handles mnuEncDefault.Click

        ConEncoding.EncoderCodePage = 0
        RefreshStatusBar()

    End Sub


    Private Sub SetEncStatusMenus()

        Me.mnuEncDefault.Text = ConEncoding.GetEncodingDisplayName(0)

        Me.mnuEnc1.Text = ConEncoding.GetEncodingDisplayName(1200)
        Me.mnuEnc2.Text = ConEncoding.GetEncodingDisplayName(1201)
        Me.mnuEnc3.Text = ConEncoding.GetEncodingDisplayName(1252)
        Me.mnuEnc4.Text = ConEncoding.GetEncodingDisplayName(12000)
        Me.mnuEnc5.Text = ConEncoding.GetEncodingDisplayName(12001)
        Me.mnuEnc6.Text = ConEncoding.GetEncodingDisplayName(20127)
        Me.mnuEnc7.Text = ConEncoding.GetEncodingDisplayName(65000)
        Me.mnuEnc8.Text = ConEncoding.GetEncodingDisplayName(65001)

        RefreshStatusBar()

    End Sub


    Private Sub RefreshStatusBar()

        Me.BtnStatusEncoding.Text = ConEncoding.GetEncodingDisplayName( _
                                    ConEncoding.EncoderCodePage)

    End Sub


    Private Sub mnuEncCustom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                   Handles mnuEncCustom.Click

        Dim EncodingForm As New FrmEncoders

        If EncodingForm.ShowDialog = Windows.Forms.DialogResult.OK Then

        End If

        RefreshStatusBar()

    End Sub


#End Region


End Class